home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GameSound.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
3KB
|
85 lines
class GameSound
{
static var created = 0;
static var baseDepth = 978944;
static var musicVolume = 35;
static var music = new GameSound();
static var initialized = GameSound.initSound();
function GameSound(sndClipID)
{
if(sndClipID != null)
{
var _loc0_ = null;
var _loc2_ = this.target = GameSound.soundBase.attachMovie(sndClipID,"sound" + GameSound.created,++GameSound.created);
}
else
{
var _loc0_ = null;
_loc2_ = this.target = GameSound.soundBase.createEmptyMovieClip("sound" + GameSound.created,++GameSound.created);
}
_loc2_._visible = false;
_loc2_.stop();
this.soundObj = new Sound(_loc2_);
this.soundObj.mc = _loc2_;
}
function startSound(linkageID, repeat)
{
this.soundObj.stop();
this.soundObj.attachSound(linkageID);
this.soundObj.start(0,!repeat ? 0 : 1048575);
}
static function playMusic(id, fadeTime, repeat)
{
if(id == null || id == "")
{
GameSound.music.soundObj.stop();
return undefined;
}
GameSound.music.soundObj.setVolume(GameSound.musicVolume);
var _loc3_ = undefined;
var _loc1_ = GameSound.music.soundObj;
_loc1_.stop();
_loc1_.attachSound(id);
_loc1_.start(0,repeat == false ? 0 : 16777215);
}
static function fadeSound(snd, targetVol, time, onComplete)
{
var _loc4_ = function(snd, st, t, sVol, oVol)
{
var _loc2_ = Math.min((getTimer() * 0.001 - st) / t,1);
snd.setVolume(Math.round(sVol + _loc2_ * oVol));
if(_loc2_ == 1)
{
onComplete(snd);
clearInterval(arguments.callee.id);
}
};
_loc4_.id = setInterval(_loc4_,0,snd,getTimer() * 0.001,time,snd.getVolume(),targetVol - snd.getVolume());
}
static function stopMusic(fadeTime)
{
snd.stop();
return undefined;
}
static function playSound(name)
{
GameSound.self.target.gotoAndStop(name);
GameSound.self.target.gotoAndStop(2);
}
static function pause()
{
GameSound.mainSound.setVolume(0);
}
static function resume()
{
GameSound.mainSound.setVolume(100);
}
static function initSound()
{
GameSound.mainSound = new Sound(GameSound.soundBase = (!_global.root ? _root : _global.root).createEmptyMovieClip("_GlobalSounds",978944));
GameSound.self = new GameSound("GlobalSounds");
GameSound.music = new GameSound();
return true;
}
}